import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: LENOVO
 * Date: 2024-08-06
 * Time: 17:14
 */
public class CardDemo {
    private static String[] suit = {"❤","♦","♣","♠"};
    public List<Card> buyCards(){
        List<Card> cardList = new ArrayList<>();//牌组
        for (int i = 1; i <= 13; i++) {
            for (int j = 0; j < 4; j++) {
                Card card = new Card(suit[j],i);
                cardList.add(card);
            }
        }
        return cardList;
    }
    public void shuffle(List<Card> cardList){
        Random random = new Random();
        for (int i = 51; i > 0 ; i--) {
            int randompos = random.nextInt(i);
            Card curCard = cardList.get(i);
            Card destCard = cardList.get(randompos);
            cardList.set(randompos,curCard);
            cardList.set(i,destCard);
        }
    }
    public void licensing(List<List<Card>> players,List<Card> cardList){
        //轮流抽牌
/*       for (int i = 0; i < 52; i++) {
            players.get(i % 3).add(cardList.get(i));
        }*/
        //五轮，每人随机抽牌
        for (int i = 0; i < 5; i++) {
            for (int j = 0; j < 3; j++) {
                Card card = cardList.remove(0);//remove返回值是被删掉的对象。这里用remove可以很好的模拟抽走动作
                players.get(j).add(card);
            }
        }
    }
}
